package org.example.service.authorization.role;

import com.bianmaba.spring.web.service.BaseService;
import org.example.bean.entity.authorization.Role;
import org.example.repository.authorization.role.RoleRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by cwx183898 on 2017/12/14.
 */
@Service
@Transactional
public class RoleService extends BaseService<Role, String> implements IRoleService {
    private static final Logger LOG = LoggerFactory.getLogger(RoleService.class);
    @Autowired
    private RoleRepository repository;

    @Override
    public RoleRepository getRepository() {
        return repository;
    }

    @Override
    public Role save(Role entity) {
        if (entity.getId() == null) {
            entity.setCreator("SYSTEM");
        }
        return super.save(entity);
    }
}
